<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<?php



class MCache implements MICache {
    private $_init = false;
    
    public function init()
    {
        if(!extension_loaded('apc'))
            throw new Exception('MCache requires PHP apc extension to be loaded.');
    }
    
    
    
    public function is_support_apc()
    {
        return $this->_init;
    }
    
    
    
    public function __construct() {
        if(!function_exists('apc_cache_info') || !($cache=@apc_cache_info('opcode'))) {
            return;
        }
        $this->_init = true;
    }

    
    public function set($key, $value, $expire = 0) {
        if ($this->_init == false) {
            return false;
        }
        return apc_store($key, $value, $expire); 
    }

    
    public function get($key){
        if ($this->_init == false) {
            return false;
        }
        return apc_fetch($key);
    }

    
    public function mget($keys) {
        if ($this->_init == false) {
            return false;
        }
        return apc_fetch($keys);
    }

    
    public function clear() {
        if ($this->_init == false) {
            return false;
        }
        return apc_clear_cache();
    }

    
    public function delete($key) {
        if ($this->_init == false) {
            return false;
        }
        return apc_delete($key);
    }

}

?>